package com.ccjq.shosestore.web.controller.home;

import com.ccjq.shosestore.product.po.HomePo;
import com.ccjq.shosestore.product.service.HomeService;
import com.ccjq.shosestore.product.service.impl.HomeServiceImpl;
import com.ccjq.shosestore.product.t_productPo.productPo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class HomeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HomeService homeService = new HomeServiceImpl();
        List<HomePo> homeList = homeService.selectAll();
        List<productPo> homeListNew = homeService.selectNew();
        List<productPo> homeListReMai = homeService.selectReMai();

        HttpSession session = request.getSession();
        session.setAttribute("homeList",homeList);
        session.setAttribute("homeListNew",homeListNew);
        session.setAttribute("homeListReMai",homeListReMai);

        request.getRequestDispatcher("/WEB-INF/jsp/home/homepageadmin.jsp").forward(request,response);
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doPost(request,response);
    }
}
